using UnityEngine;

namespace RGuang.PlathformCtrl
{

    [CreateAssetMenu(menuName = "Data/StateMachine/PlayerState/Fall", fileName = "PlayerState_Fall")]
    public class PlayerState_Fall : PlayerState
    {

        [SerializeField] AnimationCurve speedCurve;//下落速度曲线
        [SerializeField] float moveSpeed = 5f;//下落时移动速度
        public override void LogicUpdate()
        {
            if (player.IsGrounded)
            {
                stateMachine.SwitchState(typeof(PlayerState_Land));
            }

            if (input.Jump)
            {
                if (player.CanAirJump)
                {
                    stateMachine.SwitchState(typeof(PlayerState_AirJump));
                    return;
                }
                input.SetJumpInputBufferTimer();
            }

        }


        public override void PhysicUpdate()
        {
            player.SetVelocityY(speedCurve.Evaluate(stateDuration));
            player.Move(moveSpeed);
        }

    }

}
